﻿using INTEX.DataBase;
using INTEX.DataBase.Tools;
using INTEX.SCHEDULER;
using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for EditEventWindow.xaml
    /// </summary>
    public partial class VKPLIST : UserControl
    {
        CollectionViewSource vwVKPOS
        {
            get
            {
                return (CollectionViewSource)this.TryFindResource("vwVKPOS");
            }
        }
        DataRow dwVKPOS
        {
            get
            {
                try
                {
                    if (vwVKPOS.View == null)
                        return null;
                    if ((DataRowView)vwVKPOS.View.CurrentItem == null)
                        return null;
                    return ((DataRowView)vwVKPOS.View.CurrentItem).Row;
                }
                catch (Exception ex)
                {
                    return null;
                }
            }
        } 

        ApplicationBase app
        {
            get
            {
                return ApplicationBase.Instance;
            }
        }
        public INTEXDBC INTEXDBC
        {
            get
            {
                return app.INTEXDBC;
            }
        }
        public INTEXBL INTEXBL
        {
            get
            {
                return app.INTEXBL;
            }
        }
        bool IsLoaded = false;
        BindingListCollectionView cvVKP
        {
            get
            {
                return (BindingListCollectionView)CollectionViewSource.GetDefaultView(dlgVKP.ItemsSource);
            }
        }
        SETINTEXDB SetMaster
        {
            get
            {
                return MainViewModel.SetMaster;
            }
        }
        SETINTEXDB SetEnv
        {
            get
            {
                return MainViewModel.SetEnv;
            }
        }
        SETINTEXDB SetDetail
        {
            get
            {
                return MainViewModel.SetDetail;
            }
        }
        VYGRONAV95 MainViewModel;
        public VKPLIST()
        {
       
            InitializeComponent();
            this.Loaded += Windows_Loaded;
        } 
          string _sTemp = string.Empty; 
     
        void Windows_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded)
                return;
            IsLoaded = true;
            MainViewModel = (VYGRONAV95)this.DataContext; 
            vwVKPOS.View.CurrentChanged += vwVKPOS_CurrentChanged; 
        }

        void vwVKPOS_CurrentChanged(object sender, EventArgs e)
        {
            if (dwVKPOS == null)
                return;
            MainViewModel.dwVKP = dwVKPOS;
        }  
       
    }
}
